package com.itheima.util;
import com.itheima.admin.pojo.Page;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

/**
 * @Author longbosheng
 * @Date 2022/6/12 21:18
 * @PackageName:com.itheima.util
 * @ClassName: PageUitl
 * @Description: TODO
 * @Version 1.0
 */
@Log4j2
@Component
public class PageUitl {
    /*
    * 索引分页
    * */
    public static int getOffset(int page,int pageSize){
        int offset = (page-1)*pageSize;
        return offset;
    }

    public static Page getPage(Object o, int total, int page, int pageSize){
        Page page1 = new Page();
        page1.setCurrent(page);
        page1.setSize(pageSize);
        page1.setTotal(total);
        page1.setRecords(o);
        return page1;
    }
}
